package logic

import (
	"context"
	"hotel/userrpc/userrpc"

	"hotel/api/internal/svc"
	"hotel/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoLogic {
	return &UserInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserInfoLogic) UserInfo(req *types.UserInfoRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	info, err := l.svcCtx.UserRpc.UserInfo(l.ctx, &userrpc.UserInfoRequest{
		Userid:     req.Userid,
		HouseName:  req.HouseName,
		HouseImage: req.HouseImage,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "用户完善信息成功",
		Code:    200,
		Data:    info,
	}, nil
}
